package com.wenhai.spring.aop.features;

import com.wenhai.spring.aop.features.interceptor.EchoServiceMethodInterceptor;
import com.wenhai.spring.aop.features.service.DefaultEchoServiceImpl;
import com.wenhai.spring.aop.features.service.EchoService;
import org.springframework.aop.framework.ProxyFactory;

/**
 * {@link ProxyFactory}
 *
 * @author wenhai
 * @date   2021/3/5
 */
public class ProxyFactoryDemo {
    public static void main(String[] args) {
        DefaultEchoServiceImpl defaultEchoService = new DefaultEchoServiceImpl();
        ProxyFactory proxyFactory = new ProxyFactory(defaultEchoService);
        proxyFactory.addAdvice(new EchoServiceMethodInterceptor());
        EchoService echoService = (EchoService) proxyFactory.getProxy();
        System.out.println(echoService.echo("Hello,World"));
    }
}
